package com.aishua.andpaydemo.fragment;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.aishua.andpaydemo.ImageloaderHelper;
import com.aishua.andpaydemo.R;
import com.aishua.andpaydemo.activity.ChoiceColorActivity;
import com.aishua.andpaydemo.utils.TableLayoutChangeColorUtils;

/**
 * Created by aishua on 2018/5/15.
 */

public class MineFragment extends BaseFragment {

    private TextView tv_title;
    private TextView yue;
    private TextView dianhua;
    private TextView yueqian;
    private RelativeLayout title;
    private TextView tv_setting;
    private TextView tv_shiming;
    private ImageView img_title_xiaoxi;
    private ImageView img_zhutipifu;
    private ImageView img_touxiang;
    private ImageView img_wodeyemian;
    private ImageView img_wode02;
    private ImageView img_wode03;
    private TextView xingming;
    private LinearLayout ll_wodebeijing;
    View view;
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {

         view = View.inflate(getContext(), R.layout.fragment_mine,null);
//        initTitleView(view);
//        initView(view);
//        initViewData();
        return view;

    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onResume() {
        super.onResume();
        initTitleView(view);
        initView(view);
        initViewData();
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void initView(View view) {

        img_zhutipifu = view.findViewById(R.id.img_zhutipifu);
        img_touxiang = view.findViewById(R.id.img_touxiang);
        title = view.findViewById(R.id.title);
        xingming = view.findViewById(R.id.xingming);
        ll_wodebeijing = view.findViewById(R.id.ll_wodebeijing);
        tv_shiming = view.findViewById(R.id.tv_shiming);
        dianhua = view.findViewById(R.id.dianhua);
        yueqian = view.findViewById(R.id.yueqian);
        img_wode02 = view.findViewById(R.id.img_wode02);
        img_wode03 = view.findViewById(R.id.img_wode03);
        yue = view.findViewById(R.id.yue);
        img_wodeyemian = view.findViewById(R.id.img_wodeyemian);
        int clolrID = TableLayoutChangeColorUtils.getThemeColorId(getContext());

        ll_wodebeijing.setBackground(getContext().getDrawable(clolrID));
        tv_shiming.setBackground(getContext().getDrawable(clolrID));
        xingming.setTextColor(getContext().getResources().getColor(clolrID));
        dianhua.setTextColor(getContext().getResources().getColor(clolrID));
        yue.setTextColor(getContext().getResources().getColor(clolrID));
        title.setBackground(getContext().getDrawable(clolrID));
        yueqian.setTextColor(getContext().getResources().getColor(clolrID));


        img_zhutipifu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent i = new Intent(getContext(), ChoiceColorActivity.class);
                startActivity(i);
            }
        });

        ImageloaderHelper.dispalyImage(getContext(),R.drawable.wode01,img_wodeyemian);
        ImageloaderHelper.dispalyImage(getContext(),R.drawable.wode02,img_wode02);
        ImageloaderHelper.dispalyImage(getContext(),R.drawable.wode03,img_wode03);
        ImageloaderHelper.dispalyImage(getContext(),R.drawable.wodeshouyezhutipf,img_zhutipifu);

}


    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void initTitleView(View view) {

        tv_title = view.findViewById(R.id.tv_title);
        tv_setting = view.findViewById(R.id.tv_setting);
        img_title_xiaoxi = view.findViewById(R.id.img_title_xiaoxi);
    }

    private void initViewData() {

        tv_title.setText("我的");
        tv_setting.setText("设置");
        img_title_xiaoxi.setVisibility(View.INVISIBLE);
    }


}
